package vmcs.customer.coinstrategy;

import vmcs.store.Coin;
import vmcs.store.StoreItem;
import vmcs.store.StoreObject;

/**WeightCoinValidationStrategy validates the coins by comparing the weight of received coin.
 * 
 * @author Atul
 *
 */
public class WeightCoinValidationStrategy implements ICoinValidationStrategy {

	@Override
	public Coin validateCoin(StoreItem[] coins, Coin coin) {
		Coin validCoin = null;
        for (int i = 0; i < coins.length; i++) {
    		Coin coinItem=null;
            if (coins[i] != null)
            {
            	coinItem = (Coin)coins[i].getContent();
            	if ((coinItem!=null && coin!=null) && (coinItem.getWeight() == coin.getWeight()))
            		validCoin = coinItem;
        	}
        }
        return validCoin;
	}

}
